<?php
class helper_filesystem
{
    static function ls($dir)
    {
        if(!is_dir($dir))
            return false;
        $dp = opendir($dir);
        $list = array();
        while ($file = readdir($dp)) {
        	if($file == '.' || $file == '..')
        	   continue;
        	$list[] = $file;
        }
        return $list;
    }
    
    static function format_size($size) {
        $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
        if ($size == 0) { return('n/a'); } else {
        return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]); }
	}
	
	static function rewrite_php_return_array_config($filepath , $data)
	{
		$sCode = "<?php return ".var_export($data , true)."; ?>";
        file_put_contents($filepath , $sCode);
        return ;
	}
}
?>